home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2007 September / PCWSEP07.iso / Software / Linux / Linux Mint 3.0 Light / LinuxMint-3.0-Light.iso / casper / filesystem.squashfs / etc / init.d / cupsys < prev    next >
Encoding:
Text File  |  2007-04-04  |  2.4 KB  |  98 lines

  1. #! /bin/sh
  2.  
  3. PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
  4. DAEMON=/usr/sbin/cupsd
  5. NAME=cupsd
  6. PIDFILE=/var/run/cups/$NAME.pid
  7. DESC="Common Unix Printing System"
  8.  
  9. unset TMPDIR
  10.  
  11. test -f $DAEMON || exit 0
  12.  
  13. set -e
  14.  
  15. if [ -r /etc/default/cupsys ]; then
  16.   . /etc/default/cupsys
  17. fi
  18.  
  19. . /lib/lsb/init-functions
  20.  
  21. # Get the timezone set.
  22. if [ -z "$TZ" -a -e /etc/timezone ]; then
  23.     TZ=`cat /etc/timezone`
  24.     export TZ
  25. fi
  26.  
  27. case "$1" in
  28.   start)
  29.     log_begin_msg "Starting $DESC: $NAME"
  30.     chown root:lpadmin /usr/share/ppd/custom 2>/dev/null || true
  31.     chmod 3775 /usr/share/ppd/custom 2>/dev/null || true
  32.     mkdir -p `dirname "$PIDFILE"`
  33.     chown cupsys:lp `dirname "$PIDFILE"`
  34.  
  35.     # create the logs file since cupsd can't
  36.     for l in access_log page_log error_log; do
  37.         [ -e /var/log/cups/$l ] || touch /var/log/cups/$l
  38.         chmod 640 /var/log/cups/$l
  39.         chown cupsys:lpadmin /var/log/cups/$l
  40.     done
  41.  
  42.     if [ "$LOAD_LP_MODULE" = "yes" -a -f /usr/lib/cups/backend/parallel \
  43.              -a -f /proc/devices -a -f /proc/modules \
  44.          -a -x /sbin/modprobe ]; then
  45.       modprobe -q lp || true
  46.       modprobe -q ppdev || true # for ISO-1284 device name detection
  47.     fi
  48.  
  49.     start-stop-daemon --start --quiet --oknodo --pidfile "$PIDFILE" --exec $DAEMON
  50.  
  51.     # Correct the permissions after starting the CUPS daemon
  52.     for l in access_log page_log error_log; do
  53.         chmod 640 /var/log/cups/$l || true
  54.         chown cupsys:lpadmin /var/log/cups/$l || true
  55.     done
  56.  
  57.     log_end_msg $?
  58.     ;;
  59.   stop)
  60.     log_begin_msg "Stopping $DESC: $NAME"
  61.     start-stop-daemon --stop --quiet --retry 5 --oknodo --pidfile $PIDFILE --name $NAME
  62.     log_end_msg $?
  63.     ;;
  64.   restart|force-reload)
  65.     log_begin_msg "Restarting $DESC: $NAME"
  66.     if start-stop-daemon --stop --quiet --retry 5 --oknodo --pidfile $PIDFILE --name $NAME; then
  67.         start-stop-daemon --start --quiet --pidfile "$PIDFILE" --exec $DAEMON
  68.         # Correct the permissions after starting the CUPS daemon
  69.         for l in access_log page_log error_log; do
  70.             chmod 640 /var/log/cups/$l || true
  71.             chown cupsys:lpadmin /var/log/cups/$l || true
  72.         done
  73.     fi
  74.     log_end_msg $?
  75.     ;;
  76.   status)
  77.     echo -n "Status of $DESC: "
  78.     if [ ! -r "$PIDFILE" ]; then
  79.         echo "$NAME is not running."
  80.         exit 3
  81.     fi
  82.     if read pid < "$PIDFILE" && ps -p "$pid" > /dev/null 2>&1; then
  83.         echo "$NAME is running."
  84.         exit 0
  85.     else
  86.         echo "$NAME is not running but $PIDFILE exists."
  87.         exit 1
  88.     fi
  89.     ;;
  90.   *)
  91.     N=/etc/init.d/${0##*/}
  92.     echo "Usage: $N {start|stop|restart|force-reload|status}" >&2
  93.     exit 1
  94.     ;;
  95. esac
  96.  
  97. exit 0
  98.